<?php

/**
 * Offer form base class.
 *
 * @method Offer getObject() Returns the current form's model object
 *
 * @package    reduceri-cadouri
 * @subpackage form
 * @author     Your name here
 */
abstract class BaseOfferForm extends BaseFormPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'               => new sfWidgetFormInputHidden(),
      'site_id'          => new sfWidgetFormPropelChoice(array('model' => 'Site', 'add_empty' => true)),
      'unique_id'        => new sfWidgetFormInputText(),
      'name'             => new sfWidgetFormInputText(),
      'description'      => new sfWidgetFormTextarea(),
      'price'            => new sfWidgetFormInputText(),
      'full_price'       => new sfWidgetFormInputText(),
      'discount'         => new sfWidgetFormInputText(),
      'discount_percent' => new sfWidgetFormInputText(),
      'url'              => new sfWidgetFormTextarea(),
      'start_time'       => new sfWidgetFormDateTime(),
      'end_time'         => new sfWidgetFormDateTime(),
      'on_site'          => new sfWidgetFormInputCheckbox(),
      'in_search'        => new sfWidgetFormInputCheckbox(),
      'reviewed'         => new sfWidgetFormInputCheckbox(),
      'promo'            => new sfWidgetFormInputCheckbox(),
      'created_at'       => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'               => new sfValidatorChoice(array('choices' => array($this->getObject()->getId()), 'empty_value' => $this->getObject()->getId(), 'required' => false)),
      'site_id'          => new sfValidatorPropelChoice(array('model' => 'Site', 'column' => 'id', 'required' => false)),
      'unique_id'        => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'name'             => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'description'      => new sfValidatorString(array('required' => false)),
      'price'            => new sfValidatorNumber(array('required' => false)),
      'full_price'       => new sfValidatorNumber(array('required' => false)),
      'discount'         => new sfValidatorNumber(array('required' => false)),
      'discount_percent' => new sfValidatorNumber(array('required' => false)),
      'url'              => new sfValidatorString(array('required' => false)),
      'start_time'       => new sfValidatorDateTime(array('required' => false)),
      'end_time'         => new sfValidatorDateTime(array('required' => false)),
      'on_site'          => new sfValidatorBoolean(array('required' => false)),
      'in_search'        => new sfValidatorBoolean(array('required' => false)),
      'reviewed'         => new sfValidatorBoolean(array('required' => false)),
      'promo'            => new sfValidatorBoolean(array('required' => false)),
      'created_at'       => new sfValidatorDateTime(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('offer[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Offer';
  }


}
